package com.sanbuTech.util;

import org.apache.commons.lang.StringUtils;

public class CacheKeyGeneratorUtil {

	
	public static String getGeneratedKey(String key, String type){
		String returnKey = "";
		/*
		switch (type) {
		case "authCode":
			returnKey = key+"_authCode";
			break;
		case "token":
			returnKey = key +"_token";
			break;
		case "userInfo":
			returnKey = key +"_userInfo";
			break;
		case "imgAuthCode":
			returnKey = key +"_imgAuthCode";
			break;
		case "toDoList":
			returnKey = key +"_toDoList";
			break;
		default:
			break;
		}
		*/
		if(!StringUtils.isEmpty(key)){
			returnKey = key + "_" + type; 
			
		}
		return returnKey;
	}
	
	/**
	 * 生成幂等性操作的seqId的key值
	 * @param uri
	 * @param uid
	 * @return
	 */
	public static String getSeqKey(String uri, long uid){
		StringBuilder sb = new StringBuilder(uri).append(uid);
		return sb.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(CacheKeyGeneratorUtil.getGeneratedKey("token", "todoList"));
	}
}
